package org.brisling.risk.service;

import java.util.List;

import org.brisling.base.domain.ListDomain;
import org.brisling.base.domain.RetDomain;
import org.brisling.common.ConstSysParam;
import org.brisling.common.util.StringUtil;
import org.brisling.risk.domain.RiskCost;
import org.brisling.risk.domain.RiskDiag;
import org.brisling.risk.domain.RiskCost;
import org.brisling.risk.repository.RiskCostRepo;
import org.brisling.sysman.repository.RolesRepo;
import org.brisling.sysman.service.base.BaseSysmanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;


@RestController
@RequestMapping("/riskCost")
/**
 * 
 * <p>Title: RiskCostService</p>
 * <p>Description: 费用风险后台服务类</p>
 * <p>Company: tongking</p>
 * @author jackson wang
 * @since 1.0
 * @version 1.0
 * @date 2017年7月11日 下午2:45:41
 */
public class RiskCostService extends BaseSysmanService<RiskCost>{
	
	@SuppressWarnings("unused")
	@Autowired
	private RiskCostRepo baseRepo;
	
	public RiskCostService(){
		this.moduleName = ConstSysParam.MODULE_RISK_COST;
	}
	
	/**
	 * 获取业务主页面 
	 * @return
	 */
	@RequestMapping("/mainPage.action")
	public ModelAndView getMainPage(){
		return getBizMainPage();
	}
	
	/**
	 * 获取业务编辑页面
	 * @return
	 */
	@RequestMapping("/editPage.action")
	public ModelAndView getEditPage(){
		return getBizEditPage();
	}
	
	
	/**
	 * 分页查询用户列表页面
	 * @param deptid
	 * @param page
	 * @param rows
	 * @param sort
	 * @return
	 */
	@RequestMapping("/getListDomain.action")
	public ListDomain<RiskCost> getRoleListDomain(
			@RequestParam(value="page",required=false) String page,
			@RequestParam(value="rows",required=false) String rows,
			@RequestParam(value="sort",required=false) String sort){
		
				
		return super.getPagedList(page, rows);
			
	}
	
	/**
	 * 分页查询用户列表页面
	 * @param deptid
	 * @param page
	 * @param rows
	 * @param sort
	 * @return
	 */
	@RequestMapping("/getList.action")
	public List<RiskCost> getRoleList(
			@RequestParam(value="page",required=false) String page,
			@RequestParam(value="rows",required=false) String rows,
			@RequestParam(value="sort",required=false) String sort){
		
		
			return super.getAll(page,rows,getSort(sort));
			
	}
	
	/**
	 * 根据角色名称查找角色集合
	 * @param roleNames
	 * @return
	 */
	public List<RiskCost> getRoleListByRoleNames(List<String> roleNames){
		
		return super.getListByNames(roleNames);
			
	}
	
	/**
	 * 根据角色名称查找角色编码
	 * @param roleNames
	 * @return
	 */
	public List<String> getRoleIdsByRoleNames(List<String> roleNames){
		
		List<RiskCost> RiskCost = this.getRoleListByRoleNames(roleNames);
		
		
		return StringUtil.getStringIdList(RiskCost);
	}
	
	/**
	 * 删除记录,单条或批量删除记录,id不为空，执行单条删除，id为空且ids不为空，执行批量删除
	 * @param id	待删除的单条记录id
	 * @param ids	待删除的多条记录id，以','分隔
	 * @return
	 */
	@RequestMapping("/del.action")
	public RetDomain delRow(@RequestParam(value="id",required=false) Long id,@RequestParam(value="ids",required=false) String ids){
				
		return super.delRows(id, ids);		 
	}
	
	/**
	 * 删除记录,单条或批量删除记录,id不为空，执行单条删除，id为空且ids不为空，执行批量删除
	 * @param id	待删除的单条记录id
	 * @param ids	待删除的多条记录id，以','分隔
	 * @return
	 */
	@RequestMapping("/flowDel.action")
	public RetDomain delFlowRow(@RequestParam(value="id",required=false) Long id,@RequestParam(value="ids",required=false) String ids){
		
			return delRow(id,ids);
		
	}
	
	
	/**
	 * 保存业务记录
	 * @param id
	 */
	@RequestMapping("/save.action")
	public RiskCost save(@RequestBody String body){
		RiskCost role = bodyToObj(body, RiskCost.class);		
		super.save(role);
		return role;
	}
	
	/**
	 * 保存业务记录集合
	 * @param List
	 */
	@RequestMapping("/saveList.action")
	public RetDomain save(List<RiskCost> lists){
		return super.saveList(lists);
	}
	/**
	 * 查询单条业务记录
	 * @param id
	 */
	@RequestMapping("/getOne.action")
	public RiskCost getOne(@RequestParam(value="id",required=false) Long id){
		
		return super.getOne(id);
	}
	
	public RiskCost getOne(String patient_id){
		
		return baseRepo.findByPatientid(patient_id);
	}
	
	
}
